/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upeu.rrhh.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;

/**
 *
 * @author Elvis Zanguetsu
 */
public class DataBaseConexion {
    public Statement st=null;
    public Connection Conn=null; 
    public PreparedStatement ps = null;
    public ResultSet rs = null;
    public CallableStatement cs = null;
   
    public Connection getConexion(){
          
            if (Conn==null)
            try {
                Class.forName("com.mysql.jdbc.Driver");
                    Conn=(Connection)DriverManager.getConnection("jdbc:mysql://localhost/asistencia", "root", "123456");
                    System.out.println("Conexion Iniciada");
            } catch (Exception e) {
                System.out.println("DBConn.getConnection "+e.getMessage()+" Pruebe Otra Ves ");
            }

        return Conn;

        }
    
    public void closeConexion() {
    	try{
            if(st != null)
                {
                    st.close();
                }
            if(cs != null)
                {
                    cs.close();
                }
            if(rs != null)
                {
                    rs.close();
                }
            if(ps != null)
                {
                    ps.close();
                }
            if(Conn!=null) {
                Conn.close(); Conn=null; 
                
                System.out.println("Conexion Finalizada.");
        }}catch(SQLException e){
        System.out.println("ERROR! al Cerrar la Conexion :"+e);}
}
}
